package com.kzc.dao;

import com.kzc.core.MyBatisDao;
import com.kzc.entity.Member;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * Author：柯尊诚
 * Created by anyleKe on 2016/1/30.
 */
@MyBatisDao
public interface MemberDao {

    //用户注册，添加昵称，密码，电话，设备，token
    @Options(useGeneratedKeys=true, keyProperty="id")
    @Insert("insert into t_member(nickname, password, avatar, gender, phone, device, qtoken, create_time) " +
            "values(#{nickname}, #{password}, #{avatar}, #{gender}, #{phone}, #{device}, #{qtoken}, #{create_time})")
    int register(Member member);

    //用户登录
    @Select("select * from t_member where phone=#{phone} and password=#{password}")
    Member login(@Param("phone") String phone, @Param("password") String password);

    //绑定E通卡
    @Update("update t_member set e_card=#{e_card} where qtoken=#{qtoken}")
    int bindEcard(@Param("e_card") String e_card, @Param("qtoken") String qtoken);

    //绑定宿舍号
    @Update("update t_member set dormitory_no=#{dormitory_no} where qtoken=#{qtoken}")
    int bindDormitoryNo(@Param("dormitory_no") String dormitory_no, @Param("qtoken") String qtoken);

    //绑定教务信息
    @Update("update t_member set student_no=#{student_no}, student_pwd=#{student_pwd} where qtoken=#{qtoken}")
    int bindStudentInfo(@Param("student_no") String student_no, @Param("student_pwd") String student_pwd, @Param("qtoken") String qtoken);

    //修改性别
    @Update("update t_member set gender=#{gender}, update_time=#{update_time} where qtoken=#{qtoken}")
    int updateGender(Member member);

    //修改昵称
    @Update("update t_member set nickname=#{nickname}, update_time=#{update_time} where qtoken=#{qtoken}")
    int updateNick(Member member);

    //修改手机
    @Update("update t_member set phone=#{phone}, device=#{device}, update_time=#{update_time} where qtoken=#{qtoken}")
    int updatePhone(Member member);

    //修改头像名
    @Update("update t_member set avatar=#{avatar}, update_time=#{update_time} where qtoken=#{qtoken}")
    int updateAvatar(Member member);

    //修改密码
    @Update("update t_member set password=#{password}, update_time=#{update_time} where qtoken=#{qtoken}")
    int updatePassword(Member member);

    //重置密码
//    @Update("update t_member set password=#{password}, update_time=#{update_time} where qtoken=#{qtoken}")
//    int resetPassword(@Param("password") String password, @Param("update_time") String update_time, @Param("qtoken") String qtoken);

    //获取个人信息
    @Select("select * from t_member where qtoken=#{qtoken}")
    Member queryInfo(@Param("qtoken") String qtoken);

    //获取个人信息
    @Select("select * from t_member where phone=#{phone}")
    Member queryByPhone(@Param("phone") String phone);

    //修改学生姓名
    @Update("update t_member set student_name=#{student_name}, update_time=#{update_time} where qtoken=#{qtoken}")
    int updateStudentName(Member member);

    //修改专业
    @Update("update t_member set major=#{major}, update_time=#{update_time} where qtoken=#{qtoken}")
    int updateMajor(Member member);









}
